import 'package:bxultimate/app/router/router_name.dart';
import 'package:bxultimate/app/theme/app_theme.dart';
import 'package:bxultimate/data/store/auth_store.dart';
import 'package:bxultimate/widgets/mk_card_container.dart';
import 'package:bxultimate/widgets/mk_list_cell_item.dart';
import 'package:bxultimate/widgets/mk_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:tdesign_flutter/tdesign_flutter.dart';

import 'controller.dart';

class UserAccountIndexPage extends StatefulWidget {
  const UserAccountIndexPage({Key? key}) : super(key: key);

  @override
  State<UserAccountIndexPage> createState() => _UserAccountIndexPageState();
}

class _UserAccountIndexPageState extends State<UserAccountIndexPage> {
  final controller = Get.find<UserAccountIndexController>();
  final state = Get.find<UserAccountIndexController>().state;

  @override
  Widget build(BuildContext context) {
    return MkPage(
        child: Scaffold(
            backgroundColor: Colors.transparent,
            appBar: TDNavBar(
              title: '账户与安全',
              backgroundColor: Colors.transparent,
            ),
            body: ListView(
              children: <Widget>[
                _buildNav(),
              ],
            )));
  }

  _buildNav() {
    return MkCardContainer(
      padding: EdgeInsets.symmetric(horizontal: AppTheme.iDefaultPadding / 2),
      margin: EdgeInsets.symmetric(
          horizontal: AppTheme.iDefaultPadding,
          vertical: AppTheme.iDefaultPadding / 2),
      borderRadius: AppTheme.iBorderRadius,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          MkListCellItem(
            value: '手机号',
            ext: Text('${AuthStore.to.profile.mobile}'),
            press: () {},
          ),
          MkListCellItem(
            value: '登录密码',
            press: () {
              Get.toNamed(RouterName.userAccountUpdatePassword);
            },
          ),
          MkListCellItem(
            value: '微信绑定',
            ext: Text('${state.wechatName}'),
            press: () {},
          ),
          MkListCellItem(
            value: '注销账号',
            ext: TDTag(
              '注销后您的账号将无法登录',
              theme: TDTagTheme.danger,
            ),
            press: (){
              Get.toNamed(RouterName.userAccountCancel);
            },
          ),
        ],
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<UserAccountIndexController>();
    super.dispose();
  }
}
